home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / cat3 / fdopen.3 < prev    next >
Encoding:
Text File  |  1993-03-03  |  3.6 KB  |  133 lines

  1.  
  2.  
  3.  
  4. FOPEN(3)            MINTLIB LIBRARY FUNCTIONS            FOPEN(3)
  5.  
  6.  
  7. N✓NA✓AM✓ME✓E
  8.        fopen, freopen, fdopen - open a stream
  9.  
  10. S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
  11.        #include <stdio.h>
  12.  
  13.        FILE *fopen(const char *filename, const char *type);
  14.  
  15.        FILE *freopen(const char *filename, const char *type,
  16.                      FILE *stream);
  17.  
  18.        FILE *fdopen(int fd, const char *type);
  19.  
  20. D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
  21.        fopen  opens  the  file named by filename and associates a
  22.        stream with it. If the  open  succeeds,  fopen  returns  a
  23.        pointer  to  be  used to identify the stream in subsequent
  24.        operations.
  25.  
  26.        filename points to a character string  that  contains  the
  27.        name of the file to be opened.
  28.  
  29.        type is a character string starting with one the following
  30.        values:
  31.          r   - open for reading
  32.          w   - truncate or create for writing
  33.          a   - append: open for writing at end of file, or create
  34.                for writing
  35.          r+  - open for update (reading and writing)
  36.          w+  - truncate or create for update
  37.          a+  - append; open or create for update at EOF
  38.  
  39.        After one of the above, type may be followed by:
  40.          t   - open file in text mode (translate rn to n when
  41.                reading, and n to rn when writing)
  42.          b   - open file in binary mode (no r, n translation)
  43.  
  44.        If  neither 't' nor 'b' is set, the file will be opened in
  45.        the default mode set by the user. If the environment vari-
  46.        able  UNIXMODE  contains  the letter 'b', the default mode
  47.        will be binary; otherwise, the default mode is text  mode.
  48.  
  49.        freopen  opens  the  file named by filename and associates
  50.        the stream pointed to by stream with it. The type argument
  51.        is  used  just as in fopen. The original stream is closed,
  52.        regardless of whether the open ultimately succeeds. If the
  53.        open  succeeds,  freopen  returns  the  original  value of
  54.        stream.
  55.  
  56.        freopen is typically used to attach the preopened  streams
  57.        associated  with stdin, stdout, and stderr to other files.
  58.  
  59.        fdopen associates a stream with the  file  descriptor  fd.
  60.        File  descriptors  are obtained from calls like open, dup,
  61.  
  62.  
  63.  
  64. MiNT docs 0.1              3 March 1993                         1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. FOPEN(3)            MINTLIB LIBRARY FUNCTIONS            FOPEN(3)
  71.  
  72.  
  73.        creat, or  pipe,  which  open  files  but  do  not  return
  74.        streams.   Streams  are  necessary  input  for many of the
  75.        library routines.  The type of the stream must agree  with
  76.        the access permissions of the open file.
  77.  
  78.        When  a  file  is opened for update, both input and output
  79.        may be done on the resulting stream. However,  output  may
  80.        not  be  directly followed by input without an intervening
  81.        fseek or rewind, and input may not be directly followed by
  82.        output  without  an intervening fseek, rewind, or an input
  83.        operation which encounters EOF.
  84.  
  85. R✓RE✓ET✓TU✓UR✓RN✓N V✓VA✓AL✓LU✓UE✓ES✓S
  86.        On  success, fopen, freopen, and fdopen return  a  pointer
  87.        to  FILE  which identifies the opened stream.  On failure,
  88.        they return NULL.
  89.  
  90. S✓SE✓EE✓E A✓AL✓LS✓SO✓O
  91.        o✓op✓pe✓en✓n(✓(3✓3)✓),✓, p✓pi✓ip✓pe✓e(✓(3✓3)✓),✓, f✓fc✓cl✓lo✓os✓se✓e(✓(3✓3)✓),✓, f✓fs✓se✓ee✓ek✓k(✓(3✓3)✓)
  92.  
  93. B✓BU✓UG✓GS✓S
  94.        The library allows only a limited number of streams to  be
  95.        open  at  the  same  time.  Thus, a program may run out of
  96.        streams even though the system is not yet out of memory.
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. MiNT docs 0.1              3 March 1993                         2
  131.  
  132.  
  133.